//
// CBone.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CVector;

public class CBone {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CBone(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CBone obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CBone(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CBone(CBoneBase boneBase) {
    this(nel3dJNI.new_CBone(CBoneBase.getCPtr(boneBase), boneBase), true);
  }

  public String getBoneName() {
    return nel3dJNI.CBone_getBoneName(swigCPtr, this);
  }

  public int getFatherId() {
    return nel3dJNI.CBone_getFatherId(swigCPtr, this);
  }

  public CBoneBase getBoneBase() {
    return new CBoneBase(nel3dJNI.CBone_getBoneBase(swigCPtr, this), false);
  }

  public ITrack getDefaultTrack(long valueId) {
    long cPtr = nel3dJNI.CBone_getDefaultTrack(swigCPtr, this, valueId);
    return (cPtr == 0) ? null : new ITrack(cPtr, false);
  }

  public void registerToChannelMixer(CChannelMixer chanMixer, String prefix) {
    nel3dJNI.CBone_registerToChannelMixer(swigCPtr, this, CChannelMixer.getCPtr(chanMixer), chanMixer, prefix);
  }

  public void compute(CBone parent, SWIGTYPE_p_NLMISC__CMatrix rootMatrix, CSkeletonModel skeletonForAnimCtrl) {
    nel3dJNI.CBone_compute(swigCPtr, this, CBone.getCPtr(parent), parent, SWIGTYPE_p_NLMISC__CMatrix.getCPtr(rootMatrix), CSkeletonModel.getCPtr(skeletonForAnimCtrl), skeletonForAnimCtrl);
  }

  public void interpolateBoneSkinMatrix(SWIGTYPE_p_NLMISC__CMatrix otherMatrix, float interp) {
    nel3dJNI.CBone_interpolateBoneSkinMatrix(swigCPtr, this, SWIGTYPE_p_NLMISC__CMatrix.getCPtr(otherMatrix), interp);
  }

  public SWIGTYPE_p_NLMISC__CMatrix getLocalSkeletonMatrix() {
    return new SWIGTYPE_p_NLMISC__CMatrix(nel3dJNI.CBone_getLocalSkeletonMatrix(swigCPtr, this), false);
  }

  public SWIGTYPE_p_NLMISC__CMatrix getWorldMatrix() {
    return new SWIGTYPE_p_NLMISC__CMatrix(nel3dJNI.CBone_getWorldMatrix(swigCPtr, this), false);
  }

  public SWIGTYPE_p_NLMISC__CMatrix getBoneSkinMatrix() {
    return new SWIGTYPE_p_NLMISC__CMatrix(nel3dJNI.CBone_getBoneSkinMatrix(swigCPtr, this), false);
  }

  public void lodEnableChannels(CChannelMixer chanMixer, boolean enable) {
    nel3dJNI.CBone_lodEnableChannels(swigCPtr, this, CChannelMixer.getCPtr(chanMixer), chanMixer, enable);
  }

  public void forceAnimate(CChannelMixer chanMixer) {
    nel3dJNI.CBone_forceAnimate(swigCPtr, this, CChannelMixer.getCPtr(chanMixer), chanMixer);
  }

  public void setSkinScale(CVector skinScale) {
    nel3dJNI.CBone_setSkinScale(swigCPtr, this, CVector.getCPtr(skinScale), skinScale);
  }

  public CVector getSkinScale() {
    return new CVector(nel3dJNI.CBone_getSkinScale(swigCPtr, this), false);
  }

  public void set_AnimCtrl(IAnimCtrl value) {
    nel3dJNI.CBone__AnimCtrl_set(swigCPtr, this, IAnimCtrl.getCPtr(value), value);
  }

  public IAnimCtrl get_AnimCtrl() {
    long cPtr = nel3dJNI.CBone__AnimCtrl_get(swigCPtr, this);
    return (cPtr == 0) ? null : new IAnimCtrl(cPtr, false);
  }

  public void set_MaxSphere(SWIGTYPE_p_NLMISC__CBSphere value) {
    nel3dJNI.CBone__MaxSphere_set(swigCPtr, this, SWIGTYPE_p_NLMISC__CBSphere.getCPtr(value));
  }

  public SWIGTYPE_p_NLMISC__CBSphere get_MaxSphere() {
    return new SWIGTYPE_p_NLMISC__CBSphere(nel3dJNI.CBone__MaxSphere_get(swigCPtr, this), true);
  }

}
